var Comp = Window.extend({
	parent:null,
	flow:null,
	ctor:function (parent,flow, tag) {
		this._super(parent,flow, tag);
		this.parent=parent;
		this.flow=flow;
	},
	initSp:function (){
		this.comp=new Button(this.rootNode,1,TAG_COMP,"#equitment/computer_close.png",this.eventMenuCallback,this);
		this.comp.setScale(2);
		this.comp.setPosition(gg.width * 0.5, gg.height * 0.5);
		
		this.openPc=new Button(this.rootNode,2,TAG_BUTTON_OPENPC,"#equitment/c1.png",this.eventMenuCallback,this);
		this.openPc.setPosition(gg.c_width+this.comp.width-30,gg.c_height-this.comp.height+130);
		
		this.comp1=new Button(this.rootNode,1,TAG_COMP1,"#equitment/computer_open.png",this.eventMenuCallback,this);
		this.comp1.setVisible(false);
		this.comp1.setScale(2);
		this.comp1.setPosition(gg.width * 0.5, gg.height * 0.5);
		
		this.software=new Button(this.rootNode,2,TAG_BUTTON_SOFTWARE,"#software_button/software.png",this.eventMenuCallback,this);
		this.software.setPosition(gg.c_width-this.comp.width+60,gg.c_height+this.comp.width-80);
		this.software.setVisible(false);
		
		//设备
		this.button1=new Button(this.rootNode,3,TAG_BUTTON_0,"#software_button/button1_1.png",this.eventMenuCallback,this);
		this.button1.setPosition(gg.c_width*0.32,gg.c_height*1.67);
		this.button1.setVisible(false);
		//联机
		this.button2=new Button(this.rootNode,3,TAG_BUTTON_1,"#software_button/button2_1.png",this.eventMenuCallback,this);
		this.button2.setPosition(gg.c_width*0.443,gg.c_height*1.595);
		this.button2.setVisible(false);
		//光谱扫描
		this.button3=new Button(this.rootNode,3,TAG_BUTTON_2,"#software_button/button3_1.png",this.eventMenuCallback,this);
		this.button3.setPosition(gg.c_width*0.124,gg.c_height*1.009);
		this.button3.setVisible(false);
		//参数设置
		this.button4=new Button(this.rootNode,3,TAG_BUTTON_3,"#software_button/button4_1.png",this.eventMenuCallback,this);
		this.button4.setPosition(gg.c_width*0.95,gg.c_height*1.505);
		this.button4.setVisible(false);
		//确定按钮
		this.button5=new Button(this.rootNode,3,TAG_BUTTON_4,"#software_button/button5_1.png",this.eventMenuCallback,this);
		this.button5.setPosition(gg.c_width*0.935,gg.c_height*0.47);
		this.button5.setVisible(false);
		//校正
		this.button6=new Button(this.rootNode,3,TAG_BUTTON_5,"#software_button/button6_1.png",this.eventMenuCallback,this);
		this.button6.setPosition(gg.c_width*0.794,gg.c_height*1.505);
		this.button6.setVisible(false);
		//开始
		this.button7=new Button(this.rootNode,3,TAG_BUTTON_6,"#software_button/button7_1.png",this.eventMenuCallback,this);
		this.button7.setVisible(false);
		//对比图
		this.button8=new Button(this.rootNode,3,TAG_BUTTON_7,"#software_button/button8.png",this.eventMenuCallback,this);
		this.button8.setPosition(gg.width*0.85, gg.height*0.3);
		//设置精灵透明度
		this.button8.setVisible(false);
		this.button8.setOpacity(0);
		
		//定量分析
		this.button9=new Button(this.rootNode,3,TAG_BUTTON_8,"#software_button/button9_1.png",this.eventMenuCallback,this);
		this.button9.setPosition(gg.c_width*0.125,gg.c_height*1.352);
		this.button9.setVisible(false);
		//对比图
		this.button10=new Button(this.rootNode,3,TAG_BUTTON_9,"#software_button/button10.png",this.eventMenuCallback,this);
		this.button10.setPosition(gg.c_width, gg.c_height);
		this.button10.setVisible(false);
		//设置精灵透明度
		this.button10.setVisible(false);
		this.button10.setOpacity(0);
		
		this.button11=new Button(this.rootNode,3,TAG_BUTTON_10,"#software_button/button11_1.png",this.eventMenuCallback,this);
		this.button11.setPosition(gg.c_width*1.355,gg.c_height*0.319);
		this.button11.setVisible(false);
		
	},
	eventMenuCallback:function(pSender){
		this.showDesc(pSender.getTag());
		if(cur_tool != TAG_BUTTON_HAND){
			// 描述
			return;
		}
		if(!this.flow.checkTag(pSender.getTag())){
			// 是否可以触发
			_.error();
			ll.tip_layer.updateScore(gg.score);
			return;
		} else {
				_.clever();
				ll.tip_layer.updateScore(gg.score);
		}
		var action = this.flow.flow.action;
		var func = cc.callFunc(this.close, this);
		var func1=cc.callFunc(this.checkActionDone,this);
		var func2=cc.callFunc(function() {
			this.flow.next();
		}, this);
		switch (pSender.getTag()) {
		case TAG_BUTTON_OPENPC:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.parent.computer_close.setVisible(false);
				this.parent.computer_open.setVisible(true);
				this.comp.setVisible(false);
				this.comp1.setVisible(true);
				this.software.setVisible(true);
			}, this),func2));
			break;
		case TAG_BUTTON_SOFTWARE:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software_1.png");
				this.openPc.setVisible(false);
				this.comp1.setVisible(false);
				this.software.setVisible(false);
				this.button1.setVisible(true);
			},this),func2));
			break;
		case TAG_BUTTON_0:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software1.png");
				this.button1.setVisible(false);
				this.button2.setVisible(true);
			},this),func2));
			break;
		case TAG_BUTTON_1:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software_1.png");
				this.button2.setVisible(false);
				this.button3.setVisible(true);
			},this),func2));
			break;
		case TAG_BUTTON_2:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software2.png");
				this.button4.setVisible(true);
				this.button3.setVisible(false);
			},this),func2));
			break;
		case TAG_BUTTON_3:
				if(action==ACTION_DO1){
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						this.bg.setSpriteFrame("software_button/software6.png");
						this.button11.setVisible(true);
						this.button4.setVisible(false);
					},this),func2));
				}else{
					pSender.runAction(cc.sequence(cc.callFunc(function() {
						this.bg.setSpriteFrame("software_button/software3.png")
						this.button5.setVisible(true);
						this.button4.setVisible(false);
					},this),func2));
				}
			break;
		case TAG_BUTTON_4:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software2.png");
				this.button7.setPosition(gg.c_width*0.85,gg.c_height*1.5);
				this.button5.setVisible(false);
				this.button9.setVisible(false);
			},this),func,cc.delayTime(0.5),func2));
			break;
		case TAG_BUTTON_10:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.bg.setSpriteFrame("software_button/software8.png");
				this.button11.setPosition(gg.c_width*1.2,gg.c_height*0.3);
				this.button11.setVisible(false);
				this.button9.setVisible(false);
				this.button6.setVisible(true);	
			},this),func,cc.delayTime(0.5),func2));
			break;
		case TAG_BUTTON_5:
			if(action==ACTION_DO1){
				pSender.runAction(cc.sequence(cc.callFunc(function() {
					this.bg.setSpriteFrame("software_button/software7-1.png");
					this.button6.setVisible(false);
				},this),func,cc.delayTime(0.5),func2));
			}else{
				pSender.runAction(cc.sequence(func,cc.delayTime(0.5),func2));
			}
			break;
		case TAG_BUTTON_6:
			this.button7.setVisible(false);
			this.button9.setVisible(false);
			var fadein=new cc.FadeIn(0.5,100);
			if(action==ACTION_DO1){
				pSender.runAction(cc.sequence(cc.callFunc(function() {
					this.button8.setVisible(false);
					this.bg.setSpriteFrame("software_button/software7-1.png");
				},this),func2));
			}else if(action==ACTION_DO2){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-2.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO3){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-3.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO4){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-4.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO5){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-5.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO6){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-6.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO7){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-7.png")
				this.button8.runAction(cc.sequence(cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}else if(action==ACTION_DO8){
				this.button8.setVisible(false);
				this.bg.setSpriteFrame("software_button/software7-7.png");
				this.button8.runAction(cc.sequence(cc.delayTime(3),cc.callFunc(function() {
					this.bg.setSpriteFrame("end.png");
				}, this),cc.delayTime(5),func,cc.delayTime(0.5),func2));
			}else{
				this.button8.setVisible(true);
				this.bg.setSpriteFrame("software_button/software4.png")
				this.button8.runAction(cc.sequence(fadein,cc.delayTime(1),func,cc.delayTime(0.5),func2));
			}
			break;
		case TAG_BUTTON_8:
			pSender.runAction(cc.sequence(cc.callFunc(function() {
				this.button9.setVisible(false);
				this.button4.setVisible(true);
				this.bg.setSpriteFrame("software_button/software5.png");
			},this),func2));
			break;
		default:
			break;
		}
	},
	changeBG: function(resBG){
		this.bg.setSpriteFrame(resBG);
	},
	checkActionDone:function(pSender){
		var tag=pSender.getTag();
		var action = this.flow.flow.action;
	}
});